let {rand,stime} =require ("./fun");
let n=100000
let arr=rand(n)

function kuai(arr,l,r){
  if(l>=r) return

  let t=qs(arr,l,r)
  kuai(arr,l,t)
  kuai(arr,t+1,r)
}

function qs(arr,l,r){
    let v=arr[l]
    let i=l
    for(let j=l+1;j<r;j++){
        if(v>arr[j]){
            [arr[i+1],arr[j]]=[arr[j],arr[i+1]]
            i++
        }
    }
    [arr[l],arr[i]]=[arr[i],arr[l]]
    return i
}

stime(kuai,arr,0,n)
console.log(arr.slice(n-10,n))

//n=100     0ms
//n=1000    11ms
//n=10000   28ms
//n=100000  43ms